﻿using Omniscient.Foundation.ApplicationModel.Presentation;
using Omniscient.TimeTracker.Data;
using Omniscient.Foundation.Data;
using System;

namespace Omniscient.TimeTracker.TaskBarMenu
{
    public class TaskBarMenuModel : IModel
    {
        private EntityList<Client> _clients;
        private EntityList<Category> _categories;

        public TaskBarMenuModel(EntityList<Client> clients, EntityList<Category> categories)
        {
            _clients = clients;
            _categories = categories;
        }

        public EntityList<Client> Clients { get { return _clients; } }
        public EntityList<Category> Categories { get { return _categories; } }

        #region IModel Members

        public bool ContainsEntitiesThatNeedToBeSaved()
        {
            return false;
        }

        public IEntity GetEntity(Guid id)
        {
            foreach (IEntity entity in _clients)
            {
                if (entity.Id == id)
                {
                    return entity;
                }
            }

            foreach (IEntity entity in _categories)
            {
                if (entity.Id == id)
                {
                    return entity;
                }
            }

            return null;
        }

        public bool HasEntity(Guid id)
        {
            foreach (IEntity entity in _clients)
            {
                if (entity.Id == id)
                {
                    return true;
                }
            }

            foreach (IEntity entity in _categories)
            {
                if (entity.Id == id)
                {
                    return true;
                }
            }
            return false;
        }

        public string Name
        {
            get { return typeof(TaskBarMenuModel).Name; }
        }

        #endregion
    }
}